-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[Core] Support track1 and track2 mgmt SDK side by side in CLI #12952
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
add to S168 |
| from msrestazure.azure_exceptions import CloudError | ||
|
|
||
| response = sdk_no_wait(True, client.generate) | ||
| response = client.generate(raw=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so. Is sdk_not_wait useless?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, sdk_not_wait is still useful for LRO as it will set "polling" to false if no_wait is true.
But here it should not use sdk_no_wait as it's not a LRO (I checked the SDK method.)
'raw' is another story which is different from LRO, so it should not be set in sdk_no_wait.
All other places I replace 'sdk_no_wait' with 'raw=True' actually are bug fix for those modules.
In reply to: 406657030 [](ancestors = 406657030)
| from msrestazure.azure_exceptions import CloudError | ||
|
|
||
| response = sdk_no_wait(True, client.generate) | ||
| response = client.generate(raw=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can split the migration of advisor and backup to a different PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| "https://docs.microsoft.com/cli/azure/query-azure-cli?view=azure-cli-latest") | ||
| return 1 | ||
| if isinstance(ex, (CLIError, CloudError, AzureException)): | ||
| if isinstance(ex, (CLIError, CloudError, AzureException, HttpResponseError, AzureError)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional: HttpResponseError being a subclass of AzureError, you could simply catch AzureError
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lmazuel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Core changes LGTM, won't comment on advisor/backup, as suggested by @jiasli I would do atomic PR and split them, up to you.
qianwens
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
![]()
| from msrestazure.azure_exceptions import CloudError | ||
|
|
||
| response = sdk_no_wait(True, client.generate) | ||
| response = client.generate(raw=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Prasanna-Padmanabhan,
Here we pass raw=True in method instead of using sdk_no_wait (actually it's not correct to use sdk_no_wait before as client.generate is not a long running operation.), please help confirm this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have the necessary knowledge to sign off on this change. If all existing tests are passing, then you can go ahead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Prasanna-Padmanabhan, thanks for your confirm. All existing tests are passing, so we'll commit this change.
| client_kwargs['headers'] = headers | ||
|
|
||
| if 'x-ms-client-request-id' in cli_ctx.data['headers']: | ||
| client_kwargs['request_id'] = cli_ctx.data['headers']['x-ms-client-request-id'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some questions here:
request_idis required for client?- Should we use
x-ms-request-id?
x-ms-request-id: This is a common response header that contains a unique identifier for the current operation, service generated.
x-ms-client-request-id: Optional. Contains a unique ID provided by the client to identify the specific request.
It looksx-ms-client--request-idis right. #WontFix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually request_id will be set to "x-ms-client-request-id" in request header, you can check the code in azure core below:
def on_request(self, request):
# type: (PipelineRequest) -> None
"""Updates with the given request id before sending the request to the next policy.
:param request: The PipelineRequest object
:type request: ~azure.core.pipeline.PipelineRequest
"""
request_id = unset = object()
if 'request_id' in request.context.options:
request_id = request.context.options.pop('request_id')
if request_id is None:
return
elif self._request_id is None:
return
elif self._request_id is not _Unset:
request_id = self._request_id # type: ignore
elif self._auto_request_id:
request_id = str(uuid.uuid1()) # type: ignore
if request_id is not unset:
header = {"x-ms-client-request-id": request_id}
In reply to: 407376852 [](ancestors = 407376852)
da45cca to
c924cf4
Compare
Description of PR (Mandatory)
This PR does the following things to support track1 and track2 mgmt SDK side by side:
get_token()callback to support track2client_kwargsto replaceclient.configin track2HttpResponseErrorAzureErrorfrom track2rawargument for no wait and passrawexplicitly in method if necessary.parametersargument for generic update and use actual arguments in SDK instead.Testing Guide
History Notes:
(Fill in the following template if multiple notes are needed, otherwise PR title will be used for history note.)
[Component Name 1] (BREAKING CHANGE:) (az command:) make some customer-facing change.
[Component Name 2] (BREAKING CHANGE:) (az command:) make some customer-facing change.
This checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.